import request from '@/utils/request'

// 获取活动列表
export function getActivityList(params = {}) {
  return request({
    url: '/v1/admin/activities',
    method: 'GET',
    params
  })
}

// 获取活动详情
export function getActivityDetail(id) {
  return request({
    url: `/v1/admin/activities/${id}`,
    method: 'GET',
    params: {
      with_organizer: true,
      with_venue: true
    }
  })
}

// 创建活动
export function createActivity(data) {
  return request({
    url: '/v1/admin/activities',
    method: 'POST',
    data
  })
}

// 更新活动
export function updateActivity(id, data) {
  return request({
    url: `/v1/admin/activities/${id}`,
    method: 'PUT',
    data
  })
}

// 删除活动
export function deleteActivity(id) {
  return request({
    url: `/v1/admin/activities/${id}`,
    method: 'DELETE'
  })
}

// 获取活动统计数据
export function getActivityStatistics(params = {}) {
  return request({
    url: '/v1/admin/activities/statistics',
    method: 'GET',
    params
  })
}

// 获取用户活动记录
export function getUserActivityRecords(userId, params = {}) {
  return request({
    url: `/v1/admin/users/${userId}/activities`,
    method: 'GET',
    params
  })
}

// 获取用户活动统计
export function getUserActivityStats(userId, params = {}) {
  return request({
    url: `/v1/admin/users/${userId}/activities/stats`,
    method: 'GET',
    params
  })
}

// 创建用户活动记录
export function createUserActivityRecord(userId, data) {
  return request({
    url: `/v1/admin/users/${userId}/activities`,
    method: 'POST',
    data
  })
}

export default {
  getList: getActivityList,
  getDetail: getActivityDetail,
  create: createActivity,
  update: updateActivity,
  delete: deleteActivity,
  getStatistics: getActivityStatistics,
  getUserActivities: getUserActivityRecords,
  getActivityStats: getUserActivityStats,
  addActivity: createUserActivityRecord
} 